package com.ms.demo;

/**
 * @description: 创建实现媒体播放器MediaPlayer的具体实现类
 * @author: ms
 * @create: 2022-10-24 11:03
 */
public class AudioPlayer implements MediaPlayer{

    //媒体播放器的适配器
    MediaAdapter mediaAdapter;

    @Override
    public void play(String audioType, String fileName) {

        //播放 mp3 音乐文件的内置支持
        if(audioType.equalsIgnoreCase("mp3")){
            System.out.println("Playing mp3  fileName: "+ fileName);
        } else if(audioType.equalsIgnoreCase("vlc") || audioType.equalsIgnoreCase("mp4")){  //mediaAdapter 提供了播放其他文件格式的支持
            mediaAdapter = new MediaAdapter(audioType);
            mediaAdapter.play(audioType, fileName);
        } else{
            System.out.println("Invalid media. "+ audioType + " format not supported");
        }
    }
}